<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>登录</title>
    <link rel="stylesheet" href="../frame/layui/css/layui.css">
    <link rel="stylesheet" href="../frame/static/css/style.css">
    <link rel="icon" href="../frame/static/image/code.png">
</head>
<body>

<div class="login-main">
    <header class="layui-elip">后台登录</header>
    <form class="layui-form" onsubmit="return false;">
        <div class="layui-input-inline">
            <input type="text" name="name" required lay-verify="required" lay-verType="tips" placeholder="用户名"
                   autocomplete="off"
                   class="layui-input">
        </div>
        <div class="layui-input-inline">
            <input type="password" name="password" required lay-verify="required" lay-verType="tips" placeholder="密码"
                   autocomplete="off"
                   class="layui-input">
        </div>
        <div class="layui-input-inline login-btn">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
        </div>
    </form>
</div>

<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script src="../frame/layui/layui.js"></script>
<script>
    //Demo
    layui.use('form', function () {
        var form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function (data) {
            layer.msg(JSON.stringify(data.field));
            $.post('../../../action/sys.php?act=login', data.field, function (res) {
                console.log(res);
                if (res.status !== 0) {
                    layer.msg(res.msg);
                } else {
                    window.location.href = res.data;
                }
            }, 'json');
            return false;
        });
    });
</script>
</body>
</html>